<?php

if (!defined('TOBBIVM'))
	header('location:/template/notrepassing.php');
/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * create pricelist edit page
 * get: pricelist.editor.tpl.php
 *
 * @version    $Id$
 * @package    TobbiVM-Shop
 * @copyright  Copyright (C) 2012
 * @author     Norbert Gebert
 * @license    GPL3
 */
db::getInstance()->where('price_id', $refValidate->cleanslash($_GET['id']));
$result = db::getInstance()->getOne('price');

if (db::getInstance()->count <= 0)
{
	message::setErrorRow(_('Databaseerror! - Contact Admin!'), true);
}
else
{
	$refPage->assign('page_title', _('Edit Price / Pricelist'));

	$refPage->assign('Form_Start',
		'<form class="niceform fieldset" action="' .
		'index2.php?page=' . $page . '&sub=' . $subpage .
		'" method="post"><fieldset>');

	$refPage->assign('id', _('Price-ID') . '= ' . $result['price_id']);

	$refPage->assign('id', _('Price-ID') . ': ');
	$refPage->assign('idx',
		'<input type="text" name="idx" id="idx" disabled="disabled" ' .
		'size="8" value="' . $result['price_id'] . '"/>');

	$refPage->assign('name', _('Name') . ':');
	$refPage->assign('namex',
		'<input type="text" name="namex" id="namex" size="35" value="' .
		$result['price_name'] . '" />');
	$refPage->assign('namexHelp', help('pricelistname', $page));

	$refPage->assign('art', _('Price type') . ': ');

	$arty = '<select size="1" name="artx" id="artx">' . '<option value="1" ';

	/*if ($result['price_art'] == 1)
	{
		$arty .= 'selected=\'selected\'';
	}
	$arty .= '>' . '1 - ' . _('Pices x unit price') . '</option>' . '<option value="2"';
	 */
	if ($result['price_art'] == 2)
	{
		$arty .= 'selected=\'selected\'';
	}
	$arty .= '> ' . '2 - ' . _('Pices x unit price + fixed costs') . '</option>' . '<option value="3" ';
	if ($result['price_art'] == 3)
	{
		$arty .= 'selected=\'selected\'';
	}
	$arty .= '>' . '3 - ' . _('Price echelon') . '</option>' . '</select>';

	$refPage->assign('artx', $arty);

	$refPage->assign('price', _('Price per Item') . ': ');
	$refPage->assign('pricex',
		'<input type="text" name="pricex" id="pricex" size="15" value="' .
		str_replace('.', ',', $result['price_per_item']) . '" />');
	$refPage->assign('pricexHelp', help('pricelistprice', $page));

	$refPage->assign('pricefix', _('Fix-Price') . ': ');
	$refPage->assign('pricefixx',
		'<input type="text" name="pricefixx" id="pricefixx" size="15" value="' .
		str_replace('.', ',', $result['price_fix']) . '" />');
	$refPage->assign('pricefixxHelp', help('pricelistpricefix', $page));

	$refPage->assign('pricelist', _('Pricelist') . ': ');
	$refPage->assign('pricelistx',
		'<textarea name="pricelistx" id="pricelistx" rows="15" cols="45">' .
		str_replace('.', ',', $result['price_list']) . '</textarea>');
	
	$refPage->assign('pricelisttextHelp', help('pricelisttext', $page, TRUE));

	$refPage->assign('btn_save',
		'<input type="submit" name="submit" id="save" value="' .
		_('Save') . '" />');
	$refPage->assign('btn_abort',
		'<input type="submit" name="submit" id="abort" value="' .
		_('Cancel') . '" />');

	$refPage->assign('Form_End',
		'<input type="hidden" name="idx" value="' . $result['price_id'] . '">' .
		'</fieldset></form>');

	$refPage->addtpl('content', '/' . $page . '/' . $subpage . '.editor.tpl.php');
}
?>